package com.springcloud3.controller;

 import com.springcloud3.event.EventPublisher;
 import com.springcloud3.event.LoginSuccessEvent;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
//http://localhost:8080/login?username=joe&password=31
@RestController

public class LoginController {
    @Autowired
    EventPublisher eventPublisher;
    @GetMapping("/login/frist")
    public String login(@RequestParam("username") String username, @RequestParam("password") String password) {
//TODO 发送事假
        //1.准备事件
     LoginSuccessEvent event=new LoginSuccessEvent(username);
     //2.发送事件
        eventPublisher.sendEvent(event);
        //event.
//1.账户服务自动签到减分
        //2.优惠服务随机发放到优惠券
        //3.登记用户的登录信息
        return username+" 成功";
    }
}
